; Lauma

; Constants -------------------------
[Constants]
global $active
global $pause = 0
global persist $Speed = 0.5
global persist $texswap = 0
global $TargetSpeed
global $Freq = 0
global $dt
global $ts
global $moreHeld
global $lessHeld
global $anime_state = 0
post ResourceLaumaMainPosition = copy_desc ResourceLaumaMainPosition.1
post run = CustomShaderComputeAnim
post $TargetSpeed = $Speed

global persist $menu = 0
global $hold

[KeyMenu]
key = no_ctrl no_shift alt v
type = cycle
$menu = 0,1

[KeyPause]
key = no_ctrl no_shift alt p
type = cycle
$pause = 0,1

[KeyMore]
key = no_ctrl no_shift alt right
type = hold
$moreHeld = 1

[KeyLess]
key = no_ctrl no_shift alt left
type = hold
$lessHeld = 1

[KeyAnime]
key = ]
type = cycle
$anime_state = 0,1

[KeyColor]
key = VK_RIGHT
type = cycle
$texswap = 0,1

[CommandListInreaseSpeed]
$TargetSpeed = $TargetSpeed + 0.01
if $TargetSpeed >= 0.999
    $TargetSpeed = 0.999
endif
run = CommandListInterpolateSpeed

[CommandListDecreaseSpeed]
$TargetSpeed = $TargetSpeed - 0.01
if $TargetSpeed < 0
    $TargetSpeed = 0
endif
run = CommandListInterpolateSpeed

[KeyHold]
condition = $menu == 1
key = VK_LBUTTON
type = hold
$hold = 1

[Present]
if $active
    run = CustomShaderComputeAnim
    if $lessHeld
        run = CommandListDecreaseSpeed
    else if $moreHeld
        run = CommandListInreaseSpeed
    endif
    if $menu
        run = CommandListDraw
    endif
endif
post $active = 0

[CustomShaderComputeAnim]
$dt = time - $ts
$ts = time
if $anime_state == 0
    if $pause == 0
        $Freq = $Freq + $Speed * $dt
    endif
    if $Freq > 10
        $Freq = -0.05236
        $anime_state = 1
    endif
    x88 = $Freq
    cs-t50 = copy ResourceLaumaMainPosition.1
    cs-t51 = copy ResourceLaumaMainPosition.2
    cs = ./res/anim.hlsl
    cs-u5 = copy ResourceLaumaMainPosition.1
    ResourceLaumaMainPosition = ref cs-u5
    Dispatch = 44438, 1, 1
    cs-u5 = null
    cs-t50 = null
    cs-t51 = null
else if $anime_state == 1
    if $pause == 0
        $Freq = $Freq + $Speed * $dt
    endif
    if $Freq > 0.05236
        $Freq = -0.05236
	$anime_state = 2
    endif
    x88 = $Freq
    cs-t50 = copy ResourceLaumaMainPosition.1
    cs-t51 = copy ResourceLaumaMainPosition.3
    cs-u5 = copy ResourceLaumaMainPosition.1
    ResourceLaumaMainPosition = ref cs-u5
    Dispatch = 44438, 1, 1
    cs-u5 = null
    cs-t50 = null
    cs-t51 = null
else if $anime_state == 2
    if $pause == 0
        $Freq = $Freq + 5 * $dt
    endif
    if $Freq > 9
        $Freq = 0.05236
	$anime_state = 3
    endif
    x88 = $Freq
    cs-t50 = copy ResourceLaumaMainPosition.3
    cs-t51 = copy ResourceLaumaMainPosition.4
    cs-u5 = copy ResourceLaumaMainPosition.3
    ResourceLaumaMainPosition = ref cs-u5
    Dispatch = 44438, 1, 1
    cs-u5 = null
    cs-t50 = null
    cs-t51 = null
else if $anime_state == 3
    if $pause == 0
        $Freq = $Freq + $Speed * $dt
    endif
    if $Freq > 0.157
        $Freq = -0.05236
	$anime_state = 0
    endif
    x88 = $Freq
    cs-t50 = copy ResourceLaumaMainPosition.1
    cs-t51 = copy ResourceLaumaMainPosition.3
    cs-u5 = copy ResourceLaumaMainPosition.1
    ResourceLaumaMainPosition = ref cs-u5
    Dispatch = 44438, 1, 1
    cs-u5 = null
    cs-t50 = null
    cs-t51 = null
endif


; Overrides -------------------------

[TextureOverrideLaumaMainPosition]
hash = 89e96109
vb0 = ResourceLaumaMainPosition
$active = 1

[TextureOverrideLaumaMainBlend]
hash = 8226cf84
handling = skip
vb1 = ResourceLaumaMainBlend
draw = 44438, 0

[TextureOverrideLaumaMainTexcoord]
hash = d8e6d8e4
vb1 = ResourceLaumaMainTexcoord

[TextureOverrideLaumaMainVertexLimitRaise]
hash = cecefbb2
override_vertex_count = 45179
override_byte_stride = 40

[TextureOverrideLaumaMainIB]
hash = ce158bd6
handling = skip

[TextureOverrideLaumaMainHead]
hash = ce158bd6
match_first_index = 0
ib = ResourceLaumaMainHeadIB
ps-t0 = ResourceLaumaMainHeadNormalMap
ps-t1 = ResourceLaumaMainHeadDiffuse
ps-t2 = ResourceLaumaMainHeadLightMap
run = CommandList\global\ORFix\ORFix
; LaumaMainHead-vb0=89e96109.txt (5071)
drawindexed = 19074, 0, 0

[TextureOverrideLaumaMainBody]
hash = ce158bd6
match_first_index = 19074
ib = ResourceLaumaMainBodyIB
ps-t0 = ResourceLaumaMainBodyDiffuse
ps-t1 = ResourceLaumaMainBodyLightMap
; LaumaMainBody-vb0=89e96109.txt.002 (39034)
drawindexed = 188763, 0, 0
ps-t0 = ResourceLaumaMainBodyDiffuse0
ps-t1 = ResourceLaumaMainBodyLightMap0

[TextureOverrideLaumaMainDress]
hash = ce158bd6
match_first_index = 75702
ib = ResourceLaumaMainDressIB
ps-t69 = ResourceLaumaMainHeadAlphaMap
run = CommandList\TexFx\T
; LaumaMainDress-vb0=89e96109.txt (1074)
drawindexed = 4014, 0, 0

[TextureOverrideLaumaFace]
hash = 43e49ac3
this = ResourceLaumaFaceHeadDiffuse

; CommandList -----------------------
[CommandListDraw]
ps-t100 = ResourceSlider
x87 = 0.09 * res_width/res_height
y87 = 0.005
z87 = 0.42
w87 = 0.897
run = CustomShaderElement

ps-t100 = ResourceSliderPink
x87 = $Speed * x87
run = CustomShaderElement

x87 = 0.09 * res_width/res_height
run = CommandListCursor

[CommandListInterpolateSpeed]
local $td = 0.033
local $ds = ($TargetSpeed - $Speed) / $td
$Speed = $Speed + $ds * $dt

[CommandListCursor]
local $x = z87
local $y = w87
local $xo = z87 + x87
local $yo = w87 + y87
z87 = (z87 + x87 * (($Speed))) - 0.0085

run = CommandListInterpolateSpeed

if cursor_x > $x && cursor_x < $xo
    if cursor_y > $y - 0.04 && cursor_y < $yo + 0.03
        if $hold
            $TargetSpeed = ((cursor_x-$x)/($xo-$x))
        endif
    endif
endif

ps-t100 = ResourceButton
x87 = 0.01 * res_width/res_height
y87 = 0.018 * res_width/res_height
w87 = 0.883
run = CustomShaderElement

[CustomShaderElement]
vs = ./res/draw_2d.hlsl
ps = ./res/draw_2d.hlsl
blend = ADD SRC_ALPHA INV_SRC_ALPHA
cull = none
topology = triangle_strip
o0 = set_viewport bb
Draw = 4,0


; Resources -------------------------

[ResourceLaumaMainPosition]

[ResourceLaumaMainPosition.1]
type = Buffer
stride = 40
filename = LaumaMainPosition1.buf

[ResourceLaumaMainPosition.2]
type = Buffer
stride = 40
filename = LaumaMainPosition2.buf

[ResourceLaumaMainPosition.3]
type = Buffer
stride = 40
filename = LaumaMainPosition3.buf

[ResourceLaumaMainPosition.4]
type = Buffer
stride = 40
filename = LaumaMainPosition4.buf

[ResourceLaumaMainBlend]
type = Buffer
stride = 32
filename = LaumaMainBlend.buf

[ResourceLaumaMainTexcoord]
type = Buffer
stride = 20
filename = LaumaMainTexcoord.buf

[ResourceLaumaMainHeadIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = LaumaMainHead.ib

[ResourceLaumaMainBodyIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = LaumaMainBody.ib

[ResourceLaumaMainDressIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = LaumaMainDress.ib

[ResourceLaumaMainHeadNormalMap]
filename = LaumaMainHeadNormalMap.dds

[ResourceLaumaMainHeadDiffuse]
filename = LaumaMainHeadDiffuse.dds

[ResourceLaumaMainHeadLightMap]
filename = LaumaMainHeadLightMap.dds

[ResourceLaumaMainHeadAlphaMap]
filename = LaumaMainHeadAlphaMap.dds

[ResourceLaumaMainBodyDiffuse0]
filename = LaumaMainBodyDiffuse0.dds

[ResourceLaumaMainBodyLightMap0]
filename = LaumaMainBodyLightMap0.dds

[ResourceLaumaMainBodyDiffuse]
filename = LaumaMainBodyDiffuse.dds

[ResourceLaumaMainBodyLightMap]
filename = LaumaMainBodyLightMap.dds

[ResourceLaumaFaceHeadDiffuse]
filename = LaumaFaceHeadDiffuse.dds

[ResourceButton]
filename = ./res/Button.png

[ResourceSlider]
filename = ./res/Slider.png

[ResourceSliderPink]
filename = ./res/Slider_pink.png


; .ini generated by XXMI (XX-Model-Importer) v1.5.8
; If you have any issues or find any bugs, please open a ticket at https://github.com/leotorrez/XXMI-Tools/issues
